/**
 * @Description: 权限常量定义
 * 定义系统中所有的权限标识和角色权限映射
 */

// 权限标识常量
export const PERMISSIONS = {
  // 首页
  HOME: 'home',

  // 系统管理
  SYS_MANAGE: 'sys_manage',
  SYS_PERMISSION_LIST: 'sys_permission_list',
  SYS_COMPANY_LIST: 'sys_company_list',
  SYS_USER_LIST: 'sys_user_list',
  SYS_ROLE_LIST: 'sys_role_list',
  SYS_ROLE_USER_LIST: 'sys_role_user_list',

  // 用户管理
  USERS_MANAGE: 'users_manage',
  USERS_MANAGE_USER_LIST: 'users_manage_user_list',

  // 房源管理
  HOUSE_MANAGE: 'house_manage',
  HOUSE_MANAGE_HOUSE_LIST: 'house_manage_house_list',
  HOUSE_MANAGE_COMMUNITY_LIST: 'house_manage_community_list',
  HOUSE_MANAGE_RENTAL_FORM: 'house_manage_rental_form',
  HOUSE_MANAGE_DETAIL: 'house_manage_detail',

  // 按钮权限
  HOUSE_LIST_ADD_BTN: 'house_list_add_btn',
  HOUSE_LIST_DELETE_BTN: 'house_list_delete_btn',
  COMMUNITY_LIST_ADD_BTN: 'community_list_add_btn',
  COMMUNITY_LIST_DELETE_BTN: 'community_list_delete_btn',
} as const;

// 角色权限映射配置
export const ROLE_PERMISSIONS = {
  // 超级管理员 - 拥有所有权限
  admin: [
    PERMISSIONS.HOME,
    PERMISSIONS.SYS_MANAGE,
    PERMISSIONS.SYS_PERMISSION_LIST,
    PERMISSIONS.SYS_COMPANY_LIST,
    PERMISSIONS.SYS_USER_LIST,
    PERMISSIONS.SYS_ROLE_LIST,
    PERMISSIONS.SYS_ROLE_USER_LIST,
    PERMISSIONS.USERS_MANAGE,
    PERMISSIONS.USERS_MANAGE_USER_LIST,
    PERMISSIONS.HOUSE_MANAGE,
    PERMISSIONS.HOUSE_MANAGE_HOUSE_LIST,
    PERMISSIONS.HOUSE_MANAGE_COMMUNITY_LIST,
    PERMISSIONS.HOUSE_MANAGE_RENTAL_FORM,
    PERMISSIONS.HOUSE_MANAGE_DETAIL,
    PERMISSIONS.HOUSE_LIST_ADD_BTN,
    PERMISSIONS.HOUSE_LIST_DELETE_BTN,
    PERMISSIONS.COMMUNITY_LIST_ADD_BTN,
    PERMISSIONS.COMMUNITY_LIST_DELETE_BTN,
  ],

  // 运营人员 - 用户管理权限
  operator: [
    PERMISSIONS.HOME,
    PERMISSIONS.USERS_MANAGE,
    PERMISSIONS.USERS_MANAGE_USER_LIST,
  ],

  // 房源管理员 - 房源相关权限
  houseManager: [
    PERMISSIONS.HOME,
    PERMISSIONS.HOUSE_MANAGE,
    PERMISSIONS.HOUSE_MANAGE_HOUSE_LIST,
    PERMISSIONS.HOUSE_MANAGE_COMMUNITY_LIST,
    PERMISSIONS.HOUSE_MANAGE_RENTAL_FORM,
    PERMISSIONS.HOUSE_MANAGE_DETAIL,
    PERMISSIONS.HOUSE_LIST_ADD_BTN,
    PERMISSIONS.HOUSE_LIST_DELETE_BTN,
    PERMISSIONS.COMMUNITY_LIST_ADD_BTN,
    PERMISSIONS.COMMUNITY_LIST_DELETE_BTN,
  ],

  // 普通用户 - 仅查看权限
  user: [PERMISSIONS.HOME],
} as const;

// 角色中文名称映射
export const ROLE_NAMES = {
  admin: '超级管理员',
  operator: '运营人员',
  houseManager: '房源管理员',
  user: '普通用户',
} as const;

export type RoleType = keyof typeof ROLE_PERMISSIONS;
export type PermissionType = (typeof PERMISSIONS)[keyof typeof PERMISSIONS];
